package com.wen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wen.pojo.Gather;
import com.wen.pojo.dto.GatherDto;
import com.wen.pojo.vo.GatherVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GatherMapper extends BaseMapper<Gather> {

    @Select("SELECT g.*,s.stock_name FROM gather g INNER JOIN stock s WHERE g.stock_id=s.stock_id AND g.check_tag='S001-1'  OR  g.check_tag='S001-2'")
    List<Gather> GatherAll();

    Page<Gather> pageListGather(Page page,@Param("gatherVo") GatherVo gatherVo);

    @Select("SELECT g.*,s.stock_name FROM gather g,stock s WHERE g.stock_id=s.stock_id AND g.gather_order_number=#{id}")
    GatherDto gathById(String id);

    @Update("UPDATE gather t1 INNER JOIN purchase_order t2 ON t1.purchase_id = t2.purchase_id INNER JOIN `purchase_order_details` t3 ON t2.purchase_id = t3.purchase_id SET t1.check_tag='s001-2',t2.gather_tag='k001-2',t3.gather_tag='k001-2' WHERE t1.gather_order_number=#{id}")
    boolean gatherByIds(String id);


}
